<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var foo= 'get-element-by-id';
    function translate(res) {
      var arr = res.split("-"); // 以-为分隔符截取字符串，返回数组
      for(var i = 1; i < arr.length; i++) {
        arr[i] = arr[i].charAt(0).toUpperCase() + arr[i].slice(1);
      }
      res= arr.join(""); // 返回字符串
      return res;
    }
    console.log(translate(foo))
  </script>
</body>
</html>